﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:controls="clr-namespace:MiniUML.View.Controls">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/MiniUML.View;component/Resources/Styles/Controls/CommandButton.xaml"/>
    </ResourceDictionary.MergedDictionaries>
    
    <Style TargetType="{x:Type controls:CommandButton}" BasedOn="{StaticResource GenericCommandButtonStyle}">

        <Style.Resources>
            
            <Style x:Key="FocusVisualStyle">
                <Setter Property="Control.Template">
                    <Setter.Value>
                        <ControlTemplate>
                            <Border>
                                <Rectangle Margin="2" Stroke="#60000000" StrokeThickness="1" StrokeDashArray="1 2"/>
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>

            <ControlTemplate x:Key="ControlTemplate" TargetType="{x:Type controls:CommandButton}">

                <Border Padding="{TemplateBinding Padding}"
                        SnapsToDevicePixels="True"
                        CornerRadius="2"
                        BorderThickness="{TemplateBinding BorderThickness}"
                        Background="{TemplateBinding Background}"
                        BorderBrush="{TemplateBinding BorderBrush}">

                    <ContentPresenter Margin="1"
                                      HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                      VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                      RecognizesAccessKey="True"/>
                </Border>

            </ControlTemplate>

        </Style.Resources>

        <Style.Triggers>

            <Trigger Property="IsKeyboardFocused" Value="true">
                <Setter Property="BorderBrush" Value="{DynamicResource Style.Brushes.RibbonButton.DefaultedBorder}"/>
            </Trigger>
            <Trigger Property="IsMouseOver" Value="true">
                <Setter Property="Background" Value="{DynamicResource Style.Brushes.RibbonButton.MouseOverBackground}"/>
            </Trigger>
            <Trigger Property="IsPressed" Value="true">
                <Setter Property="Background" Value="{DynamicResource Style.Brushes.RibbonButton.PressedBackground}"/>
                <Setter Property="BorderBrush" Value="{DynamicResource Style.Brushes.RibbonButton.PressedBorder}"/>
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter Property="Background" Value="{DynamicResource Style.Brushes.RibbonButton.DisabledBackground}"/>
                <Setter Property="BorderBrush" Value="{DynamicResource Style.Brushes.RibbonButton.DisabledBorder}"/>
                <Setter Property="Foreground" Value="{DynamicResource Style.Brushes.RibbonButton.DisabledForeground}"/>
            </Trigger>

        </Style.Triggers>
        
        <Setter Property="Template" Value="{StaticResource ControlTemplate}"/>
        <Setter Property="FocusVisualStyle" Value="{StaticResource FocusVisualStyle}"/>

        <Setter Property="Foreground" Value="{DynamicResource Style.Brushes.RibbonButton.NormalForeground}"/>
        <Setter Property="Background" Value="{DynamicResource Style.Brushes.RibbonButton.NormalBackground}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource Style.Brushes.RibbonButton.NormalBorder}"/>

        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Padding" Value="4,2,4,1"/>
        <Setter Property="HorizontalAlignment" Value="Left"/>
        <Setter Property="VerticalAlignment" Value="Top"/>
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>

    </Style>

</ResourceDictionary>